package xuanke;

import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.ObjectInputStream;
import java.io.ObjectOutputStream;
import java.io.Serializable;

public class XuankeTest implements Serializable {

	
public static void main(String[] args) throws Exception {
Course c1=new Course("T1-1","高数","教101","周四10p.m");
Course c2=new Course("X3-3","线代","教102","周二11p.m");
Course c3=new Course("J6-6","Java","教103","周五8p.m");
Course c4=new Course("C8-8","C语言","教104","周四9p.m");
Course c5=new Course("P7-7","大物","教105","周五7p.m");
Course c6=new Course("W9-9","大物实验","综合楼","周一10p.m");

//老师开课
Teacher liu=new Teacher("2020310","刘老师","女", new Course[]{c1,c2});
Teacher hu=new Teacher("2020410","胡老师","男",new Course[]{c3,c4});
Teacher sun=new Teacher("2020210","孙老师","女",new Course[]{c5,c6});
c1.Teacherchoose(liu);
c2.Teacherchoose(liu);
c3.Teacherchoose(hu);
c4.Teacherchoose(hu);
c5.Teacherchoose(sun);
c6.Teacherchoose(sun);

//学生选课
Student cheng=new Student("609","陈小艾","女",new Course[]{c1,c2,c4,c5,c6});
Student shi=new Student("596","石小嘉","女",new Course[]{c2,c3,c4,c1,c5});



//调用退课方法
cheng.tuike(c2);
shi.tuike(c3);
//序列化对象到文件中
ObjectOutputStream oos=new ObjectOutputStream(new FileOutputStream("xuanke.bat")) ;
oos.writeObject(cheng);
oos.writeObject(shi);
oos.close();
//反序列化
File file=new File("xuanke.bat");
ObjectInputStream ois=new ObjectInputStream(new FileInputStream(file));
Student s1=(Student)ois.readObject();
System.out.println(s1.toString());
Student s2=(Student)ois.readObject();
System.out.println(s2.toString());



}


}


